import FileSaver from 'file-saver'
import XLSX from 'xlsx'

const htmlToExcel={
    getExcel(dom,title='默认标题',){
        var excelTitle=title;
        alert(excelTitle)
        var wb=XLSX.utils.table_to_book(document.querySelector(dom))
        // var wb=XLSX.utils.table_to_book(document.querySelector(dom));
        alert(wb)
        var whout=XLSX.write(wb,{bookType:"xlsx",bookSST:true,type:"array"})
        alert(wbout)
        try{
            FileSaver.saveAs(
                new Blob([wbout],{type:"application/octet-stream"}),
                excelTitle+".xlsx"
            );

        }catch (e){
            if (typeof console!=="undefined")console.log(e,wbout);
        }
        return wbout;
    }
};
export default htmlToExcel;